package com.huhui.myutil.result;

/**
 * @author 胡辉
 * @email iihuhui@163.com
 * @create 2019-07-29 21:27
 */
public class ResultUtil {
    /**
     * 默认的返回
     * success true
     *
     * @return
     */
    public static Result defaultResult() {
        return new ResponseResult();
    }

    /**
     * 成功的返回
     *
     * @param model
     * @return
     */
    public static Result successResult(Object model) {
        Result result = defaultResult();
        result.setModel(model);
        return result;
    }

    /**
     * 失败的Result
     * @param code
     * @param message
     * @return
     */
    public static Result failResult(String code, String message) {
        Result result = defaultFailResult();
        result.setResultCode(code);
        result.setMessage(message);
        return result;
    }

    /**
     * 默认的失败的result
     * @return
     */
    public static Result defaultFailResult() {
        Result result = defaultResult();
        result.setSuccess(false);
        return result;
    }
}